package app

import (
	"team-evaluate/global"
	"team-evaluate/pkg/setting"

	"github.com/go-redis/redis"
)

func NewRedisDb(redisSetting *setting.RedisSettings) (*redis.Client, error) {
	rdb := redis.NewClient(&redis.Options{
		Addr:     global.RedisSetting.Host + ":" + global.RedisSetting.Port,
		Password: global.RedisSetting.Password,
		DB:       global.RedisSetting.DBName,
		PoolSize: global.RedisSetting.PoolSize,
	})
	_, err := rdb.Ping().Result()
	if err != nil {
		return nil, err
	}
	return rdb, nil
}
